package zisu.netty.practice.netty.inBoundAndOutBound;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * @Desc: ""
 * @Author: caixiang
 * @DATE: 2020/7/29 11:17
 */
public class MyClientInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
        //加入一个出栈的handler，，对数据进行一个编码（点进去看看 就知道MyLongToByteEncoder是继承于OutboundHandler）
        pipeline.addLast(new MyLongToByteEncoder());
        //这个解码器（入栈的解码器）是 方便当服务端 向客户端传递Byte过来 解码成Long的
        //pipeline.addLast(new MyByteToLongDecoder());
        pipeline.addLast(new MyByteToLongDecoder2());
        //加入一个自定义的handler， 处理业务
        pipeline.addLast(new MyClientHandler());
    }
}
